package obecto.utility
{
	import flash.utils.Dictionary;
	
	public class DictionaryUtil
	{
		public static function getCount(dictionary : Dictionary) : Number
		{
			var count : Number = 0;
			for (var key : Object in dictionary)
			{
				count++;
			}
			return count;
		}
		
		public static function containsKey(key : Object, dictionary : Dictionary) : Boolean
		{
			return (dictionary[key] != undefined && dictionary[key] != null);
		}
		
		public static function containsAnyKey(keys : Array, dictionary : Dictionary) : Boolean
		{
			for each(var key : Object in keys)
			{
				if (containsKey(key, dictionary))
				{
					return true;	
				}
			}
			return false;
		}
		
		public static function getKey(value : Object, dictionary : Dictionary) : Object
		{
			for (var key : Object in dictionary)
			{
				if (dictionary[key] == value)
				{
					return key;
				}
			}
			return null;
		}
		
		public static function getItemsCount(dictionary : Dictionary) : int 
		{
			var count : int = 0;
			for each(var item : Object in dictionary)
			{
				count++;		
			}
			return count;
		}
	}
}